
// 泛型类求数组中的最大值
class MaxVal<T extends Comparable<T>> {
    public T findMax (T[] array) {
        T max = array[0];
        for (int i = 1; i < array.length; i++) {
            //if(max < array[i]) {
            if(max.compareTo(array[i]) < 0 ) {
                max = array[i];
            }
        }
        return max;
    }
}

public class MaxValue {

    public static void main(String[] args) {
        MaxVal<Integer> maxVal = new MaxVal<>();
        Integer[] array = {1,2,3,4,5};
        Integer ret = maxVal.findMax(array);
        System.out.println(ret);
    }
}
